<?php
class Solicitudes_Form_Recursos extends Form_Cna {
	
	private $a;
	
	public function __construct($options = null,$a=1) {
		parent::__construct($options);
	}
	
	public function init() {
	    $domConfig = Zend_Registry::get('domConfig'); //esto se crea en el bootstrap
	    $sesionRecurso = new Zend_Session_Namespace("RECURSO");
          
//		$this->setName('recursos');
		$this->setMethod("post");
		$this->setAttrib('enctype', 'multipart/form-data');
		
		$codtab        = new Zend_Form_Element_Hidden("codtab");
		$codboton      = new Zend_Form_Element_Hidden("codboton");
		$codboton2     = new Zend_Form_Element_Hidden("codboton2");
		$codrecurso     = new Zend_Form_Element_Hidden("codrecursoproceso");
		$subtiporecurso = new Zend_Form_Element_Hidden("subtiporecurso");
		$subtiporecurso->setValue($sesionRecurso->subtiporecurso);
		
		$array_elements[] = $codtab;
		$array_elements[] = $codboton;
		$array_elements[] = $codboton2;
		$array_elements[] = $codrecurso;
		$array_elements[] = $subtiporecurso;
		$array_elements[] = new Zend_Form_Element_Hidden("accion");
		
		if ($sesionRecurso->subtiporecurso==3){
			$element = new Zend_Form_Element_Text("nombrerecurso");
	        $element->setLabel("Nombre del Laboratorio : ");
	        $element->setRequired(true);
	        $element->addFilter('StripTags');
	        $element->addFilter('StringTrim');
//	        $element->addFilter('StringToUpper');
	        $element->setAttribs(array('size'=>50));
		}else{
			$element = new Zend_Form_Element_Select('tiporecurso');
			$element->setLabel("Tipo de recurso : ");
			$element->setRegisterInArrayValidator(false);
			$element->clearMultiOptions();
			$element->addMultiOption(null, "-- Seleccione --");
			$element->addMultiOptions($domConfig->RECURSOS_LOGISTICO->toArray());
	        $element->setRequired(true);
	        $element->addValidator('digits');
			$element->setOptions(array('onChange'=>'ver_ocultar_recurso(this);'));
		}
		$array_elements[] = $element;
		
        $element = new Zend_Form_Element_Text('otrorecurso');
		$element->setLabel('¿Cual? :');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("style","display:none");
		$array_elements[] = $element;
		        
        $element = new Zend_Form_Element_Text("cantidad");
        $element->setLabel("Cantidad : ");
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
        $element->addValidator('digits');
        $element->setAttrib("size", 7);
        $array_elements[] = $element;
        
        $element = new Zend_Form_Element_Text("ubicacion");
        $element->setLabel('Ubicación (sede, unidad académica) : ');
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
//        $element->addFilter('StringToUpper');
        $array_elements[] = $element;
		
		$element = new Zend_Form_Element_Textarea('descripcion');
		$element->setLabel('Descripción : (incluya las características de los recursos) :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",5);
		$element->setAttrib("style","width:99%");
		$array_elements[] = $element;
                
 		$element = new Zend_Form_Element_Select('tipounidadacademica');
		$element->setLabel("Unidad académica al que presta servicio : ");
		$element->setRegisterInArrayValidator(false);
		$element->addMultiOption(null, "-- Seleccione --");
		$element->addMultiOptions($domConfig->UNIDAD_ACADEMICA->toArray());
        $element->setRequired(true);
        $element->addValidator('digits');
		$element->setOptions(array('onChange' => 'ver_ocultar_unidad();'));
		$array_elements[] = $element;
		
        $element = new Zend_Form_Element_Text('otraunidad');
		$element->setLabel('¿Cual? :');
		$element->addFilter('StringTrim');
		$element->setAttrib("style","display:none");
//		$element->addFilter('StringToUpper');
		$array_elements[] = $element;
		
		$submit = new Zend_Form_Element_Submit ( 'btnSubmit' );
		$submit->setValue('Guardar');
		$submit->setLabel("Guardar");
		$submit->setAttrib("class", "iceCmdBtn");
		$array_elements[] = $submit;
		
		$this->addElements ($array_elements);
		
		$this->loadViewScriptDecorators();
		//$this->loadTableDecorators();
	}
	
	public function loadViewScriptDecorators() {
		$this->setDecorators ( array (array ('viewScript', array ('viewScript' => 'viewscripts/recursos_form.phtml' ) ) ) );
	}
}
?>